package com.example.lottery_system.dao.Mapper;

import com.example.lottery_system.dao.DataObject.EncryptDO;
import com.example.lottery_system.dao.DataObject.UserDO;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserMapper {
    // 查询邮箱
//    @Select("select count(1) from user where email = #{email}")
     Integer selectCountByMail(@Param("email") String email);

    // 查询电话号码
//    @Select("select count(1) from user where phone_number = #{phoneNumber}")
    Integer selectCountByPhone(@Param("phoneNumber") EncryptDO phoneNumber);


    // 插入数据
//    @Insert("insert into user(user_name, email,phone_number, password,identity) " +
//            " values(#{userName},#{email}, #{phoneNumber}, #{password}, #{identity})")
//    @Options(useGeneratedKeys = true,keyColumn = "id", keyProperty = "id")
    Integer insertUser( UserDO userDo);

//    通过邮箱来查询用户信息
//    @Select("select user_name , email, phone_number,password,`identity` from user  where email =  #{email}")
    UserDO userInfoByEmail(@Param("email") String email);

//    通过手机号来查询用户信息
//    @Select("select user_name , email, phone_number , password, `identity` from user where phone_number =  #{phoneNumber}")
    UserDO userInfoByPhone(@Param("phoneNumber") EncryptDO phoneNumber);

//    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
//    @Select("<script> select id , user_name , email, phone_number,password,`identity` from user  <if test =\" identity!=null \"> where `identity` = #{identity} </if> order by id desc  </script>\n")
    List<UserDO> selectUserListByIdentity(String identity);

    List<Long> selectIdByUserId(@Param("items") List<Long> userIdList);


    List<UserDO> selectDOByUserIds(@Param("ids") List<Long> ids);

    Integer deleteUser(@Param("userId") Long userId);
}
